package com.zhichat;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SpringBootApplication(scanBasePackages = {"com.zhichat"})
@MapperScan("com.zhichat.dao") //扫描mapper
@EnableScheduling //开启定时任务
@EnableTransactionManagement //开启事务管理
public class ZhiChatApplication {
    public static void main(String[] args) throws UnknownHostException {
//        SpringApplication.run(ZhiChatApplication.class, args);
        // spring上下文
        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(ZhiChatApplication.class, args);
        // 获取环境变量
        Environment env = configurableApplicationContext.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t"
                        + "应用 '{}' 运行成功! 访问连接:\n\t" + "地址: \t\thttp://{}:{}\r\n" + "\n"
                        + "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"));
    }

}
